package com.atguigu.gmall.order.config;

import com.atguigu.gmall.order.interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 通过配置类实现web.xml里面的拦截器配置功能，是springMvc里面的
 */
@Configuration
public class GmallWebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**");//拦截购物车里面的所有请求,请求过来先走到这里进行判断
    }
}
